﻿/**  版本信息模板在安装目录下，可自行修改。
* V_Orders_Goods.cs
*
* 功 能： N/A
* 类 名： V_Orders_Goods
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2014/5/13 10:43:09   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace BBPA.DAL
{
	/// <summary>
	/// 数据访问类:V_Orders_Goods
	/// </summary>
	public partial class V_Orders_Goods
	{
		public V_Orders_Goods()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(BBPA.Model.V_Orders_Goods model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into V_Orders_Goods(");
			strSql.Append("id,OrdersID,GoodsID,ExpectAmount,ExpectPrice,ExpectPriceSum,ActualAmount,ActualPrice,ActualPriceSum,IsAsExpect,Description,Dateandtime,Name,ShotrName,Code,SellPrice,IsPromo,IsOffShelf,CategoryName,BrandName,Number,SupplierName,SupplierNumber,PicURL,PicWidth,PicHeight,PicTitle,GoodsState,BuyPrice,ActualBuyPrice,ActualBuyPriceSum,ExpectBuyPrice,ExpectBuyPriceSum,ExpectPay,ActualPay,IsLatePay,ExpectDiscount,ExpectGiftNumber,ActualDiscount,ActualGiftNumber,ExpectBuyDiscount,ExpectBuyGiftNumber,ActualBuyDiscount,ActualBuyGiftNumber,HasBuy,SupplierShortName,SupplierID,ComeFrom,IsDelivery,Tel,Mobile,WaitSupplierCheckNum,HasCheck,HasCall4Delivery)");
			strSql.Append(" values (");
			strSql.Append("@id,@OrdersID,@GoodsID,@ExpectAmount,@ExpectPrice,@ExpectPriceSum,@ActualAmount,@ActualPrice,@ActualPriceSum,@IsAsExpect,@Description,@Dateandtime,@Name,@ShotrName,@Code,@SellPrice,@IsPromo,@IsOffShelf,@CategoryName,@BrandName,@Number,@SupplierName,@SupplierNumber,@PicURL,@PicWidth,@PicHeight,@PicTitle,@GoodsState,@BuyPrice,@ActualBuyPrice,@ActualBuyPriceSum,@ExpectBuyPrice,@ExpectBuyPriceSum,@ExpectPay,@ActualPay,@IsLatePay,@ExpectDiscount,@ExpectGiftNumber,@ActualDiscount,@ActualGiftNumber,@ExpectBuyDiscount,@ExpectBuyGiftNumber,@ActualBuyDiscount,@ActualBuyGiftNumber,@HasBuy,@SupplierShortName,@SupplierID,@ComeFrom,@IsDelivery,@Tel,@Mobile,@WaitSupplierCheckNum,@HasCheck,@HasCall4Delivery)");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4),
					new SqlParameter("@OrdersID", SqlDbType.Int,4),
					new SqlParameter("@GoodsID", SqlDbType.Int,4),
					new SqlParameter("@ExpectAmount", SqlDbType.Int,4),
					new SqlParameter("@ExpectPrice", SqlDbType.Money,8),
					new SqlParameter("@ExpectPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ActualAmount", SqlDbType.Int,4),
					new SqlParameter("@ActualPrice", SqlDbType.Money,8),
					new SqlParameter("@ActualPriceSum", SqlDbType.Money,8),
					new SqlParameter("@IsAsExpect", SqlDbType.Bit,1),
					new SqlParameter("@Description", SqlDbType.Text),
					new SqlParameter("@Dateandtime", SqlDbType.DateTime),
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@ShotrName", SqlDbType.NVarChar,50),
					new SqlParameter("@Code", SqlDbType.VarChar,50),
					new SqlParameter("@SellPrice", SqlDbType.Money,8),
					new SqlParameter("@IsPromo", SqlDbType.Bit,1),
					new SqlParameter("@IsOffShelf", SqlDbType.Bit,1),
					new SqlParameter("@CategoryName", SqlDbType.NVarChar,50),
					new SqlParameter("@BrandName", SqlDbType.NVarChar,50),
					new SqlParameter("@Number", SqlDbType.VarChar,50),
					new SqlParameter("@SupplierName", SqlDbType.NVarChar,50),
					new SqlParameter("@SupplierNumber", SqlDbType.NVarChar,50),
					new SqlParameter("@PicURL", SqlDbType.NVarChar,500),
					new SqlParameter("@PicWidth", SqlDbType.Int,4),
					new SqlParameter("@PicHeight", SqlDbType.Int,4),
					new SqlParameter("@PicTitle", SqlDbType.NVarChar,200),
					new SqlParameter("@GoodsState", SqlDbType.TinyInt,1),
					new SqlParameter("@BuyPrice", SqlDbType.Money,8),
					new SqlParameter("@ActualBuyPrice", SqlDbType.Money,8),
					new SqlParameter("@ActualBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpectBuyPrice", SqlDbType.Money,8),
					new SqlParameter("@ExpectBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpectPay", SqlDbType.Money,8),
					new SqlParameter("@ActualPay", SqlDbType.Money,8),
					new SqlParameter("@IsLatePay", SqlDbType.Bit,1),
					new SqlParameter("@ExpectDiscount", SqlDbType.Int,4),
					new SqlParameter("@ExpectGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@ActualDiscount", SqlDbType.Int,4),
					new SqlParameter("@ActualGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@ExpectBuyDiscount", SqlDbType.Int,4),
					new SqlParameter("@ExpectBuyGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@ActualBuyDiscount", SqlDbType.Int,4),
					new SqlParameter("@ActualBuyGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@HasBuy", SqlDbType.Bit,1),
					new SqlParameter("@SupplierShortName", SqlDbType.NVarChar,50),
					new SqlParameter("@SupplierID", SqlDbType.Int,4),
					new SqlParameter("@ComeFrom", SqlDbType.TinyInt,1),
					new SqlParameter("@IsDelivery", SqlDbType.Bit,1),
					new SqlParameter("@Tel", SqlDbType.NVarChar,50),
					new SqlParameter("@Mobile", SqlDbType.VarChar,50),
					new SqlParameter("@WaitSupplierCheckNum", SqlDbType.Int,4),
					new SqlParameter("@HasCheck", SqlDbType.Bit,1),
					new SqlParameter("@HasCall4Delivery", SqlDbType.Bit,1)};
			parameters[0].Value = model.id;
			parameters[1].Value = model.OrdersID;
			parameters[2].Value = model.GoodsID;
			parameters[3].Value = model.ExpectAmount;
			parameters[4].Value = model.ExpectPrice;
			parameters[5].Value = model.ExpectPriceSum;
			parameters[6].Value = model.ActualAmount;
			parameters[7].Value = model.ActualPrice;
			parameters[8].Value = model.ActualPriceSum;
			parameters[9].Value = model.IsAsExpect;
			parameters[10].Value = model.Description;
			parameters[11].Value = model.Dateandtime;
			parameters[12].Value = model.Name;
			parameters[13].Value = model.ShotrName;
			parameters[14].Value = model.Code;
			parameters[15].Value = model.SellPrice;
			parameters[16].Value = model.IsPromo;
			parameters[17].Value = model.IsOffShelf;
			parameters[18].Value = model.CategoryName;
			parameters[19].Value = model.BrandName;
			parameters[20].Value = model.Number;
			parameters[21].Value = model.SupplierName;
			parameters[22].Value = model.SupplierNumber;
			parameters[23].Value = model.PicURL;
			parameters[24].Value = model.PicWidth;
			parameters[25].Value = model.PicHeight;
			parameters[26].Value = model.PicTitle;
			parameters[27].Value = model.GoodsState;
			parameters[28].Value = model.BuyPrice;
			parameters[29].Value = model.ActualBuyPrice;
			parameters[30].Value = model.ActualBuyPriceSum;
			parameters[31].Value = model.ExpectBuyPrice;
			parameters[32].Value = model.ExpectBuyPriceSum;
			parameters[33].Value = model.ExpectPay;
			parameters[34].Value = model.ActualPay;
			parameters[35].Value = model.IsLatePay;
			parameters[36].Value = model.ExpectDiscount;
			parameters[37].Value = model.ExpectGiftNumber;
			parameters[38].Value = model.ActualDiscount;
			parameters[39].Value = model.ActualGiftNumber;
			parameters[40].Value = model.ExpectBuyDiscount;
			parameters[41].Value = model.ExpectBuyGiftNumber;
			parameters[42].Value = model.ActualBuyDiscount;
			parameters[43].Value = model.ActualBuyGiftNumber;
			parameters[44].Value = model.HasBuy;
			parameters[45].Value = model.SupplierShortName;
			parameters[46].Value = model.SupplierID;
			parameters[47].Value = model.ComeFrom;
			parameters[48].Value = model.IsDelivery;
			parameters[49].Value = model.Tel;
			parameters[50].Value = model.Mobile;
			parameters[51].Value = model.WaitSupplierCheckNum;
			parameters[52].Value = model.HasCheck;
			parameters[53].Value = model.HasCall4Delivery;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(BBPA.Model.V_Orders_Goods model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update V_Orders_Goods set ");
			strSql.Append("id=@id,");
			strSql.Append("OrdersID=@OrdersID,");
			strSql.Append("GoodsID=@GoodsID,");
			strSql.Append("ExpectAmount=@ExpectAmount,");
			strSql.Append("ExpectPrice=@ExpectPrice,");
			strSql.Append("ExpectPriceSum=@ExpectPriceSum,");
			strSql.Append("ActualAmount=@ActualAmount,");
			strSql.Append("ActualPrice=@ActualPrice,");
			strSql.Append("ActualPriceSum=@ActualPriceSum,");
			strSql.Append("IsAsExpect=@IsAsExpect,");
			strSql.Append("Description=@Description,");
			strSql.Append("Dateandtime=@Dateandtime,");
			strSql.Append("Name=@Name,");
			strSql.Append("ShotrName=@ShotrName,");
			strSql.Append("Code=@Code,");
			strSql.Append("SellPrice=@SellPrice,");
			strSql.Append("IsPromo=@IsPromo,");
			strSql.Append("IsOffShelf=@IsOffShelf,");
			strSql.Append("CategoryName=@CategoryName,");
			strSql.Append("BrandName=@BrandName,");
			strSql.Append("Number=@Number,");
			strSql.Append("SupplierName=@SupplierName,");
			strSql.Append("SupplierNumber=@SupplierNumber,");
			strSql.Append("PicURL=@PicURL,");
			strSql.Append("PicWidth=@PicWidth,");
			strSql.Append("PicHeight=@PicHeight,");
			strSql.Append("PicTitle=@PicTitle,");
			strSql.Append("GoodsState=@GoodsState,");
			strSql.Append("BuyPrice=@BuyPrice,");
			strSql.Append("ActualBuyPrice=@ActualBuyPrice,");
			strSql.Append("ActualBuyPriceSum=@ActualBuyPriceSum,");
			strSql.Append("ExpectBuyPrice=@ExpectBuyPrice,");
			strSql.Append("ExpectBuyPriceSum=@ExpectBuyPriceSum,");
			strSql.Append("ExpectPay=@ExpectPay,");
			strSql.Append("ActualPay=@ActualPay,");
			strSql.Append("IsLatePay=@IsLatePay,");
			strSql.Append("ExpectDiscount=@ExpectDiscount,");
			strSql.Append("ExpectGiftNumber=@ExpectGiftNumber,");
			strSql.Append("ActualDiscount=@ActualDiscount,");
			strSql.Append("ActualGiftNumber=@ActualGiftNumber,");
			strSql.Append("ExpectBuyDiscount=@ExpectBuyDiscount,");
			strSql.Append("ExpectBuyGiftNumber=@ExpectBuyGiftNumber,");
			strSql.Append("ActualBuyDiscount=@ActualBuyDiscount,");
			strSql.Append("ActualBuyGiftNumber=@ActualBuyGiftNumber,");
			strSql.Append("HasBuy=@HasBuy,");
			strSql.Append("SupplierShortName=@SupplierShortName,");
			strSql.Append("SupplierID=@SupplierID,");
			strSql.Append("ComeFrom=@ComeFrom,");
			strSql.Append("IsDelivery=@IsDelivery,");
			strSql.Append("Tel=@Tel,");
			strSql.Append("Mobile=@Mobile,");
			strSql.Append("WaitSupplierCheckNum=@WaitSupplierCheckNum,");
			strSql.Append("HasCheck=@HasCheck,");
			strSql.Append("HasCall4Delivery=@HasCall4Delivery");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4),
					new SqlParameter("@OrdersID", SqlDbType.Int,4),
					new SqlParameter("@GoodsID", SqlDbType.Int,4),
					new SqlParameter("@ExpectAmount", SqlDbType.Int,4),
					new SqlParameter("@ExpectPrice", SqlDbType.Money,8),
					new SqlParameter("@ExpectPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ActualAmount", SqlDbType.Int,4),
					new SqlParameter("@ActualPrice", SqlDbType.Money,8),
					new SqlParameter("@ActualPriceSum", SqlDbType.Money,8),
					new SqlParameter("@IsAsExpect", SqlDbType.Bit,1),
					new SqlParameter("@Description", SqlDbType.Text),
					new SqlParameter("@Dateandtime", SqlDbType.DateTime),
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@ShotrName", SqlDbType.NVarChar,50),
					new SqlParameter("@Code", SqlDbType.VarChar,50),
					new SqlParameter("@SellPrice", SqlDbType.Money,8),
					new SqlParameter("@IsPromo", SqlDbType.Bit,1),
					new SqlParameter("@IsOffShelf", SqlDbType.Bit,1),
					new SqlParameter("@CategoryName", SqlDbType.NVarChar,50),
					new SqlParameter("@BrandName", SqlDbType.NVarChar,50),
					new SqlParameter("@Number", SqlDbType.VarChar,50),
					new SqlParameter("@SupplierName", SqlDbType.NVarChar,50),
					new SqlParameter("@SupplierNumber", SqlDbType.NVarChar,50),
					new SqlParameter("@PicURL", SqlDbType.NVarChar,500),
					new SqlParameter("@PicWidth", SqlDbType.Int,4),
					new SqlParameter("@PicHeight", SqlDbType.Int,4),
					new SqlParameter("@PicTitle", SqlDbType.NVarChar,200),
					new SqlParameter("@GoodsState", SqlDbType.TinyInt,1),
					new SqlParameter("@BuyPrice", SqlDbType.Money,8),
					new SqlParameter("@ActualBuyPrice", SqlDbType.Money,8),
					new SqlParameter("@ActualBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpectBuyPrice", SqlDbType.Money,8),
					new SqlParameter("@ExpectBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpectPay", SqlDbType.Money,8),
					new SqlParameter("@ActualPay", SqlDbType.Money,8),
					new SqlParameter("@IsLatePay", SqlDbType.Bit,1),
					new SqlParameter("@ExpectDiscount", SqlDbType.Int,4),
					new SqlParameter("@ExpectGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@ActualDiscount", SqlDbType.Int,4),
					new SqlParameter("@ActualGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@ExpectBuyDiscount", SqlDbType.Int,4),
					new SqlParameter("@ExpectBuyGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@ActualBuyDiscount", SqlDbType.Int,4),
					new SqlParameter("@ActualBuyGiftNumber", SqlDbType.Int,4),
					new SqlParameter("@HasBuy", SqlDbType.Bit,1),
					new SqlParameter("@SupplierShortName", SqlDbType.NVarChar,50),
					new SqlParameter("@SupplierID", SqlDbType.Int,4),
					new SqlParameter("@ComeFrom", SqlDbType.TinyInt,1),
					new SqlParameter("@IsDelivery", SqlDbType.Bit,1),
					new SqlParameter("@Tel", SqlDbType.NVarChar,50),
					new SqlParameter("@Mobile", SqlDbType.VarChar,50),
					new SqlParameter("@WaitSupplierCheckNum", SqlDbType.Int,4),
					new SqlParameter("@HasCheck", SqlDbType.Bit,1),
					new SqlParameter("@HasCall4Delivery", SqlDbType.Bit,1)};
			parameters[0].Value = model.id;
			parameters[1].Value = model.OrdersID;
			parameters[2].Value = model.GoodsID;
			parameters[3].Value = model.ExpectAmount;
			parameters[4].Value = model.ExpectPrice;
			parameters[5].Value = model.ExpectPriceSum;
			parameters[6].Value = model.ActualAmount;
			parameters[7].Value = model.ActualPrice;
			parameters[8].Value = model.ActualPriceSum;
			parameters[9].Value = model.IsAsExpect;
			parameters[10].Value = model.Description;
			parameters[11].Value = model.Dateandtime;
			parameters[12].Value = model.Name;
			parameters[13].Value = model.ShotrName;
			parameters[14].Value = model.Code;
			parameters[15].Value = model.SellPrice;
			parameters[16].Value = model.IsPromo;
			parameters[17].Value = model.IsOffShelf;
			parameters[18].Value = model.CategoryName;
			parameters[19].Value = model.BrandName;
			parameters[20].Value = model.Number;
			parameters[21].Value = model.SupplierName;
			parameters[22].Value = model.SupplierNumber;
			parameters[23].Value = model.PicURL;
			parameters[24].Value = model.PicWidth;
			parameters[25].Value = model.PicHeight;
			parameters[26].Value = model.PicTitle;
			parameters[27].Value = model.GoodsState;
			parameters[28].Value = model.BuyPrice;
			parameters[29].Value = model.ActualBuyPrice;
			parameters[30].Value = model.ActualBuyPriceSum;
			parameters[31].Value = model.ExpectBuyPrice;
			parameters[32].Value = model.ExpectBuyPriceSum;
			parameters[33].Value = model.ExpectPay;
			parameters[34].Value = model.ActualPay;
			parameters[35].Value = model.IsLatePay;
			parameters[36].Value = model.ExpectDiscount;
			parameters[37].Value = model.ExpectGiftNumber;
			parameters[38].Value = model.ActualDiscount;
			parameters[39].Value = model.ActualGiftNumber;
			parameters[40].Value = model.ExpectBuyDiscount;
			parameters[41].Value = model.ExpectBuyGiftNumber;
			parameters[42].Value = model.ActualBuyDiscount;
			parameters[43].Value = model.ActualBuyGiftNumber;
			parameters[44].Value = model.HasBuy;
			parameters[45].Value = model.SupplierShortName;
			parameters[46].Value = model.SupplierID;
			parameters[47].Value = model.ComeFrom;
			parameters[48].Value = model.IsDelivery;
			parameters[49].Value = model.Tel;
			parameters[50].Value = model.Mobile;
			parameters[51].Value = model.WaitSupplierCheckNum;
			parameters[52].Value = model.HasCheck;
			parameters[53].Value = model.HasCall4Delivery;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from V_Orders_Goods ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public BBPA.Model.V_Orders_Goods GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,OrdersID,GoodsID,ExpectAmount,ExpectPrice,ExpectPriceSum,ActualAmount,ActualPrice,ActualPriceSum,IsAsExpect,Description,Dateandtime,Name,ShotrName,Code,SellPrice,IsPromo,IsOffShelf,CategoryName,BrandName,Number,SupplierName,SupplierNumber,PicURL,PicWidth,PicHeight,PicTitle,GoodsState,BuyPrice,ActualBuyPrice,ActualBuyPriceSum,ExpectBuyPrice,ExpectBuyPriceSum,ExpectPay,ActualPay,IsLatePay,ExpectDiscount,ExpectGiftNumber,ActualDiscount,ActualGiftNumber,ExpectBuyDiscount,ExpectBuyGiftNumber,ActualBuyDiscount,ActualBuyGiftNumber,HasBuy,SupplierShortName,SupplierID,ComeFrom,IsDelivery,Tel,Mobile,WaitSupplierCheckNum,HasCheck,HasCall4Delivery from V_Orders_Goods ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

			BBPA.Model.V_Orders_Goods model=new BBPA.Model.V_Orders_Goods();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public BBPA.Model.V_Orders_Goods DataRowToModel(DataRow row)
		{
			BBPA.Model.V_Orders_Goods model=new BBPA.Model.V_Orders_Goods();
			if (row != null)
			{
				if(row["id"]!=null && row["id"].ToString()!="")
				{
					model.id=int.Parse(row["id"].ToString());
				}
				if(row["OrdersID"]!=null && row["OrdersID"].ToString()!="")
				{
					model.OrdersID=int.Parse(row["OrdersID"].ToString());
				}
				if(row["GoodsID"]!=null && row["GoodsID"].ToString()!="")
				{
					model.GoodsID=int.Parse(row["GoodsID"].ToString());
				}
				if(row["ExpectAmount"]!=null && row["ExpectAmount"].ToString()!="")
				{
					model.ExpectAmount=int.Parse(row["ExpectAmount"].ToString());
				}
				if(row["ExpectPrice"]!=null && row["ExpectPrice"].ToString()!="")
				{
					model.ExpectPrice=decimal.Parse(row["ExpectPrice"].ToString());
				}
				if(row["ExpectPriceSum"]!=null && row["ExpectPriceSum"].ToString()!="")
				{
					model.ExpectPriceSum=decimal.Parse(row["ExpectPriceSum"].ToString());
				}
				if(row["ActualAmount"]!=null && row["ActualAmount"].ToString()!="")
				{
					model.ActualAmount=int.Parse(row["ActualAmount"].ToString());
				}
				if(row["ActualPrice"]!=null && row["ActualPrice"].ToString()!="")
				{
					model.ActualPrice=decimal.Parse(row["ActualPrice"].ToString());
				}
				if(row["ActualPriceSum"]!=null && row["ActualPriceSum"].ToString()!="")
				{
					model.ActualPriceSum=decimal.Parse(row["ActualPriceSum"].ToString());
				}
				if(row["IsAsExpect"]!=null && row["IsAsExpect"].ToString()!="")
				{
					if((row["IsAsExpect"].ToString()=="1")||(row["IsAsExpect"].ToString().ToLower()=="true"))
					{
						model.IsAsExpect=true;
					}
					else
					{
						model.IsAsExpect=false;
					}
				}
				if(row["Description"]!=null)
				{
					model.Description=row["Description"].ToString();
				}
				if(row["Dateandtime"]!=null && row["Dateandtime"].ToString()!="")
				{
					model.Dateandtime=DateTime.Parse(row["Dateandtime"].ToString());
				}
				if(row["Name"]!=null)
				{
					model.Name=row["Name"].ToString();
				}
				if(row["ShotrName"]!=null)
				{
					model.ShotrName=row["ShotrName"].ToString();
				}
				if(row["Code"]!=null)
				{
					model.Code=row["Code"].ToString();
				}
				if(row["SellPrice"]!=null && row["SellPrice"].ToString()!="")
				{
					model.SellPrice=decimal.Parse(row["SellPrice"].ToString());
				}
				if(row["IsPromo"]!=null && row["IsPromo"].ToString()!="")
				{
					if((row["IsPromo"].ToString()=="1")||(row["IsPromo"].ToString().ToLower()=="true"))
					{
						model.IsPromo=true;
					}
					else
					{
						model.IsPromo=false;
					}
				}
				if(row["IsOffShelf"]!=null && row["IsOffShelf"].ToString()!="")
				{
					if((row["IsOffShelf"].ToString()=="1")||(row["IsOffShelf"].ToString().ToLower()=="true"))
					{
						model.IsOffShelf=true;
					}
					else
					{
						model.IsOffShelf=false;
					}
				}
				if(row["CategoryName"]!=null)
				{
					model.CategoryName=row["CategoryName"].ToString();
				}
				if(row["BrandName"]!=null)
				{
					model.BrandName=row["BrandName"].ToString();
				}
				if(row["Number"]!=null)
				{
					model.Number=row["Number"].ToString();
				}
				if(row["SupplierName"]!=null)
				{
					model.SupplierName=row["SupplierName"].ToString();
				}
				if(row["SupplierNumber"]!=null)
				{
					model.SupplierNumber=row["SupplierNumber"].ToString();
				}
				if(row["PicURL"]!=null)
				{
					model.PicURL=row["PicURL"].ToString();
				}
				if(row["PicWidth"]!=null && row["PicWidth"].ToString()!="")
				{
					model.PicWidth=int.Parse(row["PicWidth"].ToString());
				}
				if(row["PicHeight"]!=null && row["PicHeight"].ToString()!="")
				{
					model.PicHeight=int.Parse(row["PicHeight"].ToString());
				}
				if(row["PicTitle"]!=null)
				{
					model.PicTitle=row["PicTitle"].ToString();
				}
                try
                {
                    if (row["GoodsState"] != null && row["GoodsState"].ToString() != "")
                    {
                        model.GoodsState = int.Parse(row["GoodsState"].ToString());
                    }
                }
                catch
                {
                    model.GoodsState = 1;
                }
				if(row["BuyPrice"]!=null && row["BuyPrice"].ToString()!="")
				{
					model.BuyPrice=decimal.Parse(row["BuyPrice"].ToString());
				}
				if(row["ActualBuyPrice"]!=null && row["ActualBuyPrice"].ToString()!="")
				{
					model.ActualBuyPrice=decimal.Parse(row["ActualBuyPrice"].ToString());
				}
				if(row["ActualBuyPriceSum"]!=null && row["ActualBuyPriceSum"].ToString()!="")
				{
					model.ActualBuyPriceSum=decimal.Parse(row["ActualBuyPriceSum"].ToString());
				}
				if(row["ExpectBuyPrice"]!=null && row["ExpectBuyPrice"].ToString()!="")
				{
					model.ExpectBuyPrice=decimal.Parse(row["ExpectBuyPrice"].ToString());
				}
				if(row["ExpectBuyPriceSum"]!=null && row["ExpectBuyPriceSum"].ToString()!="")
				{
					model.ExpectBuyPriceSum=decimal.Parse(row["ExpectBuyPriceSum"].ToString());
				}
				if(row["ExpectPay"]!=null && row["ExpectPay"].ToString()!="")
				{
					model.ExpectPay=decimal.Parse(row["ExpectPay"].ToString());
				}
				if(row["ActualPay"]!=null && row["ActualPay"].ToString()!="")
				{
					model.ActualPay=decimal.Parse(row["ActualPay"].ToString());
				}
				if(row["IsLatePay"]!=null && row["IsLatePay"].ToString()!="")
				{
					if((row["IsLatePay"].ToString()=="1")||(row["IsLatePay"].ToString().ToLower()=="true"))
					{
						model.IsLatePay=true;
					}
					else
					{
						model.IsLatePay=false;
					}
				}
				if(row["ExpectDiscount"]!=null && row["ExpectDiscount"].ToString()!="")
				{
					model.ExpectDiscount=int.Parse(row["ExpectDiscount"].ToString());
				}
				if(row["ExpectGiftNumber"]!=null && row["ExpectGiftNumber"].ToString()!="")
				{
					model.ExpectGiftNumber=int.Parse(row["ExpectGiftNumber"].ToString());
				}
				if(row["ActualDiscount"]!=null && row["ActualDiscount"].ToString()!="")
				{
					model.ActualDiscount=int.Parse(row["ActualDiscount"].ToString());
				}
				if(row["ActualGiftNumber"]!=null && row["ActualGiftNumber"].ToString()!="")
				{
					model.ActualGiftNumber=int.Parse(row["ActualGiftNumber"].ToString());
				}
				if(row["ExpectBuyDiscount"]!=null && row["ExpectBuyDiscount"].ToString()!="")
				{
					model.ExpectBuyDiscount=int.Parse(row["ExpectBuyDiscount"].ToString());
				}
				if(row["ExpectBuyGiftNumber"]!=null && row["ExpectBuyGiftNumber"].ToString()!="")
				{
					model.ExpectBuyGiftNumber=int.Parse(row["ExpectBuyGiftNumber"].ToString());
				}
				if(row["ActualBuyDiscount"]!=null && row["ActualBuyDiscount"].ToString()!="")
				{
					model.ActualBuyDiscount=int.Parse(row["ActualBuyDiscount"].ToString());
				}
				if(row["ActualBuyGiftNumber"]!=null && row["ActualBuyGiftNumber"].ToString()!="")
				{
					model.ActualBuyGiftNumber=int.Parse(row["ActualBuyGiftNumber"].ToString());
				}
				if(row["HasBuy"]!=null && row["HasBuy"].ToString()!="")
				{
					if((row["HasBuy"].ToString()=="1")||(row["HasBuy"].ToString().ToLower()=="true"))
					{
						model.HasBuy=true;
					}
					else
					{
						model.HasBuy=false;
					}
				}
				if(row["SupplierShortName"]!=null)
				{
					model.SupplierShortName=row["SupplierShortName"].ToString();
				}
				if(row["SupplierID"]!=null && row["SupplierID"].ToString()!="")
				{
					model.SupplierID=int.Parse(row["SupplierID"].ToString());
				}
				if(row["ComeFrom"]!=null && row["ComeFrom"].ToString()!="")
				{
					model.ComeFrom=int.Parse(row["ComeFrom"].ToString());
				}
				if(row["IsDelivery"]!=null && row["IsDelivery"].ToString()!="")
				{
					if((row["IsDelivery"].ToString()=="1")||(row["IsDelivery"].ToString().ToLower()=="true"))
					{
						model.IsDelivery=true;
					}
					else
					{
						model.IsDelivery=false;
					}
				}
				if(row["Tel"]!=null)
				{
					model.Tel=row["Tel"].ToString();
				}
				if(row["Mobile"]!=null)
				{
					model.Mobile=row["Mobile"].ToString();
				}
				if(row["WaitSupplierCheckNum"]!=null && row["WaitSupplierCheckNum"].ToString()!="")
				{
					model.WaitSupplierCheckNum=int.Parse(row["WaitSupplierCheckNum"].ToString());
				}
				if(row["HasCheck"]!=null && row["HasCheck"].ToString()!="")
				{
					if((row["HasCheck"].ToString()=="1")||(row["HasCheck"].ToString().ToLower()=="true"))
					{
						model.HasCheck=true;
					}
					else
					{
						model.HasCheck=false;
					}
				}
				if(row["HasCall4Delivery"]!=null && row["HasCall4Delivery"].ToString()!="")
				{
					if((row["HasCall4Delivery"].ToString()=="1")||(row["HasCall4Delivery"].ToString().ToLower()=="true"))
					{
						model.HasCall4Delivery=true;
					}
					else
					{
						model.HasCall4Delivery=false;
					}
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select id,OrdersID,GoodsID,ExpectAmount,ExpectPrice,ExpectPriceSum,ActualAmount,ActualPrice,ActualPriceSum,IsAsExpect,Description,Dateandtime,Name,ShotrName,Code,SellPrice,IsPromo,IsOffShelf,CategoryName,BrandName,Number,SupplierName,SupplierNumber,PicURL,PicWidth,PicHeight,PicTitle,GoodsState,BuyPrice,ActualBuyPrice,ActualBuyPriceSum,ExpectBuyPrice,ExpectBuyPriceSum,ExpectPay,ActualPay,IsLatePay,ExpectDiscount,ExpectGiftNumber,ActualDiscount,ActualGiftNumber,ExpectBuyDiscount,ExpectBuyGiftNumber,ActualBuyDiscount,ActualBuyGiftNumber,HasBuy,SupplierShortName,SupplierID,ComeFrom,IsDelivery,Tel,Mobile,WaitSupplierCheckNum,HasCheck,HasCall4Delivery ");
			strSql.Append(" FROM V_Orders_Goods ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" id,OrdersID,GoodsID,ExpectAmount,ExpectPrice,ExpectPriceSum,ActualAmount,ActualPrice,ActualPriceSum,IsAsExpect,Description,Dateandtime,Name,ShotrName,Code,SellPrice,IsPromo,IsOffShelf,CategoryName,BrandName,Number,SupplierName,SupplierNumber,PicURL,PicWidth,PicHeight,PicTitle,GoodsState,BuyPrice,ActualBuyPrice,ActualBuyPriceSum,ExpectBuyPrice,ExpectBuyPriceSum,ExpectPay,ActualPay,IsLatePay,ExpectDiscount,ExpectGiftNumber,ActualDiscount,ActualGiftNumber,ExpectBuyDiscount,ExpectBuyGiftNumber,ActualBuyDiscount,ActualBuyGiftNumber,HasBuy,SupplierShortName,SupplierID,ComeFrom,IsDelivery,Tel,Mobile,WaitSupplierCheckNum,HasCheck,HasCall4Delivery ");
			strSql.Append(" FROM V_Orders_Goods ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM V_Orders_Goods ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T. desc");
			}
			strSql.Append(")AS Row, T.*  from V_Orders_Goods T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "V_Orders_Goods";
			parameters[1].Value = "";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

